<?php
    require_once './handler/check_session.php';
    require_once './data/Banque.php';
    
    $banque = unserialize($_SESSION['banque']);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
        <title>Inscription</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <link rel="STYLESHEET" type="text/css" href="style/header_footer_style.css" />
        <link rel="STYLESHEET" type="text/css" href="style/main_style.css" />
        <link rel="STYLESHEET" type="text/css" href="style/pwdwidget.css" />
        <script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
        <script type="text/javascript" src="scripts/pwdwidget.js"></script>      
    </head>
    <body>
        <!-- HEADER -->
        <?php include_once './include/header.php'; ?>
        <!-- MAIN -->
        <div id="main">
            <!-- CONTENT -->  
			<fieldset id='fieldset_group' class='list_banque'>
				<legend>Liste des banques</legend>
				<table>
					<tr>
						<th style="width: 400px;"><b>Nom</b></th>
						<th style="width: 300px;"><b>Login</b></th>
					</tr>
                    <?php foreach (Banque::getListAllBanque() as $banque){ ?>
					<tr onmouseover="this.className='highlight'" onmouseout="this.className='normal'">
						<td><?php  echo $banque->nom ?></td>
						<td><?php  echo $banque->login ?></td>
					</tr>
					<?php } ?>
				</table>
			</fieldset>
			<form id='contactmail' action='./handler/send_mail_mdp_forgot.php' method='post' accept-charset='UTF-8'>
				<fieldset id='fieldset_group' class='list_banque' style="margin-top: 15px;">
					<legend>Demande mot de passe</legend>
					<label>Login de la banque :</label>&nbsp;<input type='text' name='login' id='login' />&nbsp;&nbsp;<input type='submit' name='valider' value="Envoyer" />
				</fieldset>
			</form>           
        </div>
        <!-- FOOTER -->
        <?php include_once './include/footer.php'; ?>
    </body>
</html>
<script>
function checkmdp()
{
	if(document.getElementById("mdp").value != "")
	{
		document.getElementById("new_mdp").disabled = false;
		document.getElementById("check_new_mdp").disabled = false;
	}else{

		document.getElementById("new_mdp").disabled = true;
		document.getElementById("check_new_mdp").disabled = true;
	}
}

function checkFields()
{

var isgood = checkFieldsEmpty();

if(!isgood)
	return;

 var isgood = checkFieldsMdpEquals();

 if(!isgood)
	 return;

 	document.forms["modify"].submit();
 		
	
}

function checkFieldsEmpty()
{
	var listValue = ["name", "address","phone", "email"];
	var good = true;
	
	for(var i= 0; i < listValue.length; i++)
	{
		var val = listValue[i];
		var fieldValue = document.getElementById(val);

		if(fieldValue.value == null || fieldValue.value == "")
		{
			fieldValue.style.border = 'red 2px solid';
			fieldValue.style.backgroundColor = '#FDF1B8';
			if(good)
				good = false;
		}else{
			fieldValue.style.border = '';
			fieldValue.style.backgroundColor = '';
		}

	}


	if(!good)
	{
		alert("Certains éléments obligatoires sont manquants");
	}

	return good;

}


function checkFieldsMdpEquals()
{
	
	var pwd = document.getElementById("mdp").value;
	var new_pwd = document.getElementById("new_mdp").value;
	var new_pwd2 = document.getElementById("check_new_mdp").value;


	if(pwd != null && pwd != "")
	{
		if(new_pwd != new_pwd2)
		{
			alert("Les 2 mots de passe ne correspondent pas");
			return false;
		}
	}

	return true;

}
</script>